/*
 * 文件名：ShopCategoryService.java
 * 版权：Copyright by www.huawei.com
 * 描述：
 * 修改人：zhangshaohua
 * 修改时间：2016年4月12日
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */

package com.zcsy.manage.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zcsy.manage.model.base.ShopCatagoryView;
import com.zcsy.manage.model.base.ShopCategory;
import com.zcsy.manage.persistence.base.ShopCategoryDao;
import com.zcsy.manage.service.base.IShopCategoryService;
import com.zcsy.manage.service.system.impl.SystemComService;

@Service
public class ShopCategoryService extends SystemComService implements IShopCategoryService {

	@Autowired
	private ShopCategoryDao shopCategoryDao;
	
	@Override
	public int insert(ShopCategory shopCategory) {
		return shopCategoryDao.insert(shopCategory);
	}

	@Override
	public int update(ShopCategory shopCategory) {
		ShopCategory oldCategory = shopCategoryDao.selectByPrimaryKey(shopCategory.getId());
		
		oldCategory.setName(shopCategory.getName());
		oldCategory.setLevel(shopCategory.getLevel());
		oldCategory.setParentId(shopCategory.getParentId());
		oldCategory.setLogo(shopCategory.getLogo());
		oldCategory.setSort(shopCategory.getSort());
		oldCategory.setDescrip(shopCategory.getDescrip());
		oldCategory.setMemo(shopCategory.getMemo());
		oldCategory.setUserAccount(shopCategory.getUserAccount());
		oldCategory.setUpdateTime(shopCategory.getUpdateTime());
		
		return shopCategoryDao.update(oldCategory);
	}

	@Override
	public int deleteByPrimaryKey(String id) {
		return shopCategoryDao.deleteByPrimaryKey(id);
	}

	@Override
	public ShopCategory selectByPrimaryKey(String id) {
		return shopCategoryDao.selectByPrimaryKey(id);
	}

	@Override
	public List<ShopCatagoryView> selectByKeyword(ShopCategory shopCatagory) {
		return shopCategoryDao.selectByKeyword(shopCatagory);
	}

	@Override
	public List<ShopCategory> getAllShopcategory() {
		return shopCategoryDao.getAllShopcategory();
	}

	@Override
	public List<ShopCategory> getParentBylevel(int level) {
		return shopCategoryDao.getParentBylevel(level);
	}

	@Override
	public List<ShopCategory> getCategoryByparentId(String parentId) {
		return shopCategoryDao.getCategoryByparentId(parentId);
	}

	@Override
	public List<ShopCategory> getShopCategoryByCellId(String cellId) {
		return shopCategoryDao.getShopCategoryByCellId(cellId);
	}
}
